<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>自定义URI方案&跨域请求演示</title>
</head>

<body>
    <div> 当前页面资源是通过具有自定义方案的URL加载的</div>
    <img src="voldp://home/EdgeWebView2-80.jpg" />
    <img src="voldp://home/aaaa.png" />

    <p>XMLHttpRequest读取<a href="voldp://home/ScenarioCustomScheme.json">ScenarioCustomScheme.json</a>中的内容</p>
    <textarea id="text" cols="90" rows="10"></textarea>
    <button onclick="getJson()">读取</button>
    <script>
        function getJson() {
            var xhr = new XMLHttpRequest();
            xhr.open("GET", "voldp://home/ScenarioCustomScheme.json");
            xhr.send(null);
            xhr.onload = function (e) {
                var xhr = e.target;
                console.log(xhr.responseText);
                var text = document.getElementById("text")
                text.value = xhr.responseText
            }
        }
    </script>
    <p>跨域读取 baidu.com (跨域功能需要在环境创建前设置"关闭同源策略")</p>
    <textarea id="text1" cols="90" rows="10"></textarea>
    <button onclick="request()">读取</button>
    <script>
        function request() {
            var xhr = new XMLHttpRequest();
            xhr.open("GET", "http://baidu.com");
            xhr.send(null);
            xhr.onload = function (e) {
                var xhr = e.target;
                console.log(xhr.responseText);
                var text = document.getElementById("text1")
                text.value = xhr.responseText
            }
        }
    </script>
</body>

</html>